//package com.coldchain;
//
//
//import com.coldchain.admin.config.entity.City;
//import com.coldchain.admin.config.service.ICityService;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.poi.ss.usermodel.Row;
//import org.apache.poi.ss.usermodel.Sheet;
//import org.apache.poi.ss.usermodel.Workbook;
//import org.apache.poi.ss.usermodel.WorkbookFactory;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import java.io.FileInputStream;
//import java.io.InputStream;
//import java.util.ArrayList;
//import java.util.List;
//
//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = AdminBootstrap.class)
//public class ImportExcel {
//
//    @Autowired
//    private ICityService cityService;
//
//
//    private City currentNode;
//
//    private City currentn;
//
//    private List<City> cities=new ArrayList<>();
//
//
//    private Sheet currentSheet;
//
//    private int countRow=0;
//    private Workbook wb;
//
//    private  Sheet sheet;
//
//    @Test
//    public  void  readExcelTitle() {
//        try {
//            InputStream is = new FileInputStream("/home/zona/Desktop/AMap_adcode_citycode.xlsx");
//            wb = WorkbookFactory.create(is);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        sheet=wb.getSheetAt(0);
//        countRow=sheet.getPhysicalNumberOfRows();
//
//        Row firstRow=sheet.getRow(sheet.getFirstRowNum());
//
//
//        for (int i=1;i<=countRow-1;i++){
//             Row row=sheet.getRow(i);
//             int cellSize=row.getPhysicalNumberOfCells();
//             String cityCode="";
//             String adeCode=row.getCell(1).getStringCellValue();
//             String cityName=row.getCell(0).getStringCellValue();
//             if(cellSize==3){
//                 cityCode=row.getCell(2).getStringCellValue();
//             }
//             if(StringUtils.isEmpty(cityCode)){
//
//                 if(!cities.isEmpty()){
//                     cityService.saveBatch(cities);
//                     cities.clear();
//                 }
//                // currentNode=new City(cityName,cityCode,adeCode);
//                 cityService.save(currentNode);
//             }else {
//                // cities.add(new City(cityName,cityCode,adeCode,currentNode.getId()));
//             }
//        }
//        if(!cities.isEmpty()){
//            cityService.saveBatch(cities);
//        }
//
//    }
//
//
//
//
//
//}
